home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
626-650
/
641
/
tlog
/
monthtot.tlog
< prev
next >
Wrap
Text File
|
1995-03-15
|
5KB
|
164 lines
/*
* MonthTot.tlog
* AREXX report for TLog that prints the total monthly distances and compare
* the monthly total with the total for SearchKey records.
*/
/*
* Start at the begining of the data base and keep getting the next record
* and add up any distances until you get to the end. Right now the only
* way to tell you're at the end is when nextrec result is lastrec
*
* 'Filter out' any record containing the key SearchKey. It's distance is
* summed in a different stem variable and printed for comparison.
*/
/*
* SearchKey is the 1st argument to MonthTot.tlog. If no argument is
* specified, then default to GOAL.
*/
PARSE UPPER ARG SearchKey
IF SearchKey = "" THEN SearchKey = "GOAL"
OPTIONS RESULTS
OPTIONS FAILAT 10
/* add the necessary libraries */
IF(~EXISTS("libs:rexxsupport.library")|~EXISTS("libs:rexxarplib.library")|~EXISTS("libs:screenshare.library")) THEN
DO
SAY "Couldn't find needed library (rexxsupport, rexxarplib, screenshare, or rexxmathlib)."
EXIT 20
END
IF ~SHOW('L','rexxsupport.library') THEN
CALL ADDLIB('rexxsupport.library',0,-30)
IF ~SHOW('L','rexxarplib.library') THEN
CALL ADDLIB('rexxarplib.library',0,-30)
IF ~SHOW('L','rexxmathlib.library') THEN
CALL ADDLIB('rexxmathlib.library',0,-30)
/* setup the port to tlog */
ADDRESS 'TLOG'
/* Open our window */
CALL open out,"con:0/0/640/170/Monthly Training Totals "|| SearchKey
IF ~RESULT THEN DO
SAY "Open failure ... sorry"
EXIT 10
END
CSI = '9B'x
/* Initialize the a table of monthly totals */
distance.JAN.total = 0; distance.JAN.SearchKey = 0;
distance.FEB.total = 0; distance.FEB.SearchKey = 0;
distance.MAR.total = 0; distance.MAR.SearchKey = 0;
distance.APR.total = 0; distance.APR.SearchKey = 0;
distance.MAY.total = 0; distance.MAY.SearchKey = 0;
distance.JUN.total = 0; distance.JUN.SearchKey = 0;
distance.JUL.total = 0; distance.JUL.SearchKey = 0;
distance.AUG.total = 0; distance.AUG.SearchKey = 0;
distance.SEP.total = 0; distance.SEP.SearchKey = 0;
distance.OCT.total = 0; distance.OCT.SearchKey = 0;
distance.NOV.total = 0; distance.NOV.SearchKey = 0;
distance.DEC.total = 0; distance.DEC.SearchKey = 0;
distance.YEAR.total = 0; distance.YEAR.SearchKey = 0;
/* use TLog dateformat MMM DD YY and grab the 1st 3 chars as the month */
GetDateFormat
oldFormat = RESULT
DateFormat 4
/*
* IF you have been making entries into the data base, it is best to
* flush its buffers by doing a close first.
*/
CloseDB
/* Open the data base and mark the END record */
OpenDB
LastRec
lastDataRecord = RESULT
/*
* Here the distance field, dbdist, is added to the running total for the
* month. The month is found by extracting a substring of the date field,
* dbdate. We also filter out (don't add) any distance that comes from a record
* with a particular dbkey, SearchKey, and save them in a another stem.
*/
/* get the first record and its data */
FirstRec
IF (rc~=0) THEN EXIT rc
/* Now loop forever, or until nextrec yields the last record */
DO FOREVER
/* After the date, the fields in a record are delineated by spaces */
PARSE VAR RESULT '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
month = SUBSTR(dbdate,1,3)
PARSE UPPER VAR dbkey testkey '.'
/* Is the SearchKey is a substring of the current key? */
IF INDEX(testkey, SearchKey, 1) ~= 0 THEN DO
distance.month.SearchKey = distance.month.SearchKey + dbdist
distance.YEAR.SearchKey = distance.YEAR.SearchKey + dbdist
END
ELSE DO /* save all other distances in the monthly total */
distance.month.total = distance.month.total + dbdist
distance.YEAR.total = distance.YEAR.total + dbdist
END
IF ( (rc~=0) | ( RESULT = lastDataRecord )) THEN BREAK
NextRec
END
/* restore the date format */
DateFormat oldFormat
CALL SCREENTOFRONT()
/* Now generate your reports printing out our monthly totals */
/* tab is column 15x of the current line */
tab = '0D'x CSI'15C'
CALL writeln out, "Total distances by month:"
/* put up label in bold color 1 and restore */
CALL writech out, CSI'1;33;40m'
CALL writeln out, " Actual" tab SearchKey
CALL writech out, CSI'0;31;40m'
CALL writeln out, " " JAN distance.JAN.total tab distance.JAN.SearchKey
CALL writeln out, " " FEB distance.FEB.total tab distance.FEB.SearchKey
CALL writeln out, " " MAR distance.MAR.total tab distance.MAR.SearchKey
CALL writeln out, " " APR distance.APR.total tab distance.APR.SearchKey
CALL writeln out, " " MAY distance.MAY.total tab distance.MAY.SearchKey
CALL writeln out, " " JUN distance.JUN.total tab distance.JUN.SearchKey
CALL writeln out, " " JUL distance.JUL.total tab distance.JUL.SearchKey
CALL writeln out, " " AUG distance.AUG.total tab distance.AUG.SearchKey
CALL writeln out, " " SEP distance.SEP.total tab distance.SEP.SearchKey
CALL writeln out, " " OCT distance.OCT.total tab distance.OCT.SearchKey
CALL writeln out, " " NOV distance.NOV.total tab distance.NOV.SearchKey
CALL writeln out, " " DEC distance.DEC.total tab distance.DEC.SearchKey
CALL writeln out,"-------------------------"
CALL writeln out, " TOT" distance.YEAR.total tab distance.YEAR.SearchKey
CALL writeln out, " "
/* put up prompt in color 2 */
CALL writech out, CSI'0;32;40m'
CALL writeln out, "Press <Return> to exit"
CALL readln out
CALL SCREENTOBACK()
EXIT